package com.catazy.module_collect.repository

import com.catazy.module_collect.bean.CollectBean
import com.catazy.module_collect.network.HttpService
import com.catazy.wanandroid.common_base.bean.HttpResult
import kotlinx.coroutines.flow.Flow

/**
 * 作者: Tao
 * 日期: 2024/4/15
 * 时间: 9:59
 * 描述: 收藏仓库
 */
class CollectRepository {

    companion object {
        val instance: CollectRepository by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
            CollectRepository()
        }
    }

    /**
     * 收藏文章
     */
    fun collectArticle(id: Int): Flow<HttpResult<CollectBean>> {
        return HttpService.service.addCollectArticle(id)
    }

    /**
     * 取消收藏文章
     */
    fun unCollectArticle(id: Int): Flow<HttpResult<CollectBean>> {
        return HttpService.service.cancelCollectArticle(id)
    }
}